package nayasis.common.db.manager.sql.condition;

import java.util.List;

import nayasis.common.db.manager.sql.condition.node.Node;
import nayasis.common.db.manager.sql.type.Type;

public class Expression extends Node {

    private List<Expression> expressions = null;
    
    private String context = "";
    
    public Expression( String context ) {
        
        super( Type.expression );
        
        List<Node> nodes = new NodeParser().parse( context );
        
        
        if( context == null ) return;
        
        context = context.trim();
        
        if( context.length() == 0 ) return;

        expressions = new BraceParser().parse( context );
        
        if( expressions != null ) return;
        
        this.context = context;
        
    }
    
    public Expression( List<Node> nodes ) {
        
        super( Type.expression );
        
    }

    public List<Expression> getExpressions() {
        return this.expressions;
    }
    
    public String toString() {
        
        if( expressions == null ) return this.context;
        
        return expressions.toString();
    
    }
}
